// 已有的地下城币: 0 角色星级: 2 已有碎片: 50
// 每天可获取3000(vh地下城、开月卡)地下城币 800币可换取5碎片
// 可通过花费地下城币手动刷新兑换列表 前4次刷新每次花费10地下城币 只考虑每天最多刷新4次的情况
// 这里只计算每天只兑换一名角色的情况

const characterUpgradeDebrisCost = {
  0: 15,
  1: 30,
  2: 100,
  3: 120,
  4: 150
}
let coin = 0
const character = {
  star: 3,
  debris: 1
}
const coinDailyObtain = 3000
let round = 1
while (true) {
  coin += coinDailyObtain
  if (coin >= 800) {
    coin -= 800
    character.debris += 5
  }
  if (character.debris >= characterUpgradeDebrisCost[character.star]) {
    character.debris = character.debris % characterUpgradeDebrisCost[character.star]
    character.star += 1
  }
  let refreshCount = 0
  while (coin >= 810 && refreshCount < 4) {
    coin -= 810
    refreshCount += 1
    character.debris += 5
    if (character.debris >= characterUpgradeDebrisCost[character.star]) {
      character.debris = character.debris % characterUpgradeDebrisCost[character.star]
      character.star += 1
    }
  }
  console.log(`第${round}天, 角色星级:${character.star}, 已有碎片:${character.debris}, 剩余地下城币: ${coin}, 手动刷新${refreshCount}次`)
  if (character.star === 5) {
    break
  }
  round += 1
}
console.log(`花费${round}天`)
